package com.mntp.proxy.cglibdemo;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class CglibProxyInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        System.out.println("CGLIB 代理：方法调用前 - " + method.getName());
        Object result = proxy.invokeSuper(obj, args);  // 调用父类（目标类）的方法
        System.out.println("CGLIB 代理：方法调用后 - " + method.getName());
        return result;
    }
}
